package com.service.company.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dao.company.CompanyDao;
import com.domain.company.Company;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.service.company.CompanyService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.UUID;

@Service
public class CompanyServiceImpl implements CompanyService {

    @Autowired
    private CompanyDao companyDao;

    @Override
    public PageInfo findAll(Integer page, Integer size) {
//        page = (page-1)*size;
//        List<Company> companys = companyDao.findAll(page, size);
        PageHelper.startPage(page, size);
        List<Company> list = companyDao.findAll(page, size);
        return new PageInfo(list);
    }

    @Override
    public Integer save(Company company) {
        company.setId(UUID.randomUUID().toString());
        companyDao.save(company);
        return null;
    }

    @Override
    public Integer update(Company company) {
        companyDao.update(company);
        return null;
    }

    @Override
    public Integer delete(String id) {
        companyDao.delete(id);
        return null;
    }

    @Override
    public Company findById(String id) {
        Company company = companyDao.findById(id);
        return company;
    }

//    @Override
//    public Long findAllTotal() {
//        return companyDao.findAllTotal();
//    }


}
